<?php
require_once("conf/db_connection.php");


$size = $_GET['size'];
$fleet = $_GET['fleet'];
$stat = $_GET['stat'];
$filter_date = $_GET['filter_date'];

if($filter_date=="" || $filter_date==null)
{
	$query_queue="SELECT * FROM trip_detail WHERE (container_size LIKE '%".$size."%' AND status LIKE '%".$stat."%') AND (status='queue' OR status='for confirmation') AND is_cancelled='0'";
}
else
{
	$query_queue="SELECT * FROM trip_detail WHERE (container_size LIKE '%".$size."%' AND status LIKE '%".$stat."%') AND (status='queue' OR status='for confirmation') AND is_cancelled='0' AND receive_date_time LIKE '".$filter_date."%'";
}
//AND fleet_group LIKE '%".$fleet."%'
$result_queue=mysql_query($query_queue);


$lbl_size = $size==""?"All":$size."FTR";
$lbl_fleet = $fleet==""?"All":$fleet;
$lbl_stat = $stat==""?"All":$stat;

$lbl_size = "<span style='font-style:italic'>".$lbl_size."</span>";
$lbl_fleet = "<span style='font-style:italic'>".$lbl_fleet."</span>";
$lbl_stat = strtoupper("<span style='font-style:italic'>".$lbl_stat."</span>");

$search_string = "<span style='color:white'><span style='font-weight:bold;'>Size:</span> ".$lbl_size."&nbsp;&nbsp;&nbsp; <span style='font-weight:bold;'>Fleet Group:</span> ".$lbl_fleet."&nbsp;&nbsp;&nbsp; <span style='font-weight:bold;'>Status:</span> ".$lbl_stat."</span>&nbsp;&nbsp;&nbsp;";
?>
<html>
<head>
<script type="text/javascript" src="lib/js/main.js"></script>
<script type="text/javascript" src="lib/js/jquery-1.7.1.js"></script>
<link rel="stylesheet" href="lib/js/jqueryui/css/blitzer/jquery-ui-1.8.17.custom.css">
<!--<link rel="stylesheet" href="lib/js/jqueryui/css/ui-lightness/jquery-ui-1.8.17.custom.css">-->
<script type="text/javascript" src="lib/js/jqueryui/js/jquery-ui-1.8.17.custom.min.js"></script>
<script type='text/javascript'>
function popSearch()
{
	xmlhttp_assign=GetXmlHttpObject();
	if (xmlhttp_assign==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }
	var url="ajax_asearch_queue2.php";
	xmlhttp_assign.onreadystatechange=function (){
	  if (xmlhttp_assign.readyState==4)
	  {
		parent.disableDiv();
		parent.document.getElementById("pop_div_search").innerHTML = xmlhttp_assign.responseText;
		parent.showPopSearchDiv();
	  }
	}
	xmlhttp_assign.open("GET",url,true);
	xmlhttp_assign.send(null);	
}
</script>
<style type = "text/css">
#hor-minimalist-b {
	background-color: #FFFFFF;
    border-collapse: collapse;
    font-family: Georgia;
    font-size: 12px;
    margin: 10px;
    text-align: left;
    width: 900px;
}
#hor-minimalist-b th {
    border-bottom: 2px solid #5F0C0C ;
    color: #5F0C0C;
    font-size: 12px;
    font-weight: bold;
    padding: 10px 8px;
}
#hor-minimalist-b td {
    border-bottom: 1px solid #888888;
    color: #000000;
    padding: 6px 8px;
}
#hor-minimalist-b tbody tr:hover td {
    //color: #0000CC;
	background-color:#BCC5C6;
}
<style type='text/css'>
/* css for timepicker */
.ui-timepicker-div .ui-widget-header { margin-bottom: 8px; }
.ui-timepicker-div dl { text-align: left; }
.ui-timepicker-div dl dt { height: 25px; margin-bottom: -25px; }
.ui-timepicker-div dl dd { margin: 0 10px 10px 65px; }
.ui-timepicker-div td { font-size: 90%; }
.ui-tpicker-grid-label { background: none; border: none; margin: 0; padding: 0; }
</style>
</style>
<script>
function popAssign(id)
{
	xmlhttp_assign=GetXmlHttpObject();
	if (xmlhttp_assign==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }
	var url="ajax_pop_assign.php";
	url=url+"?id="+id;
	xmlhttp_assign.onreadystatechange=function (){
	  if (xmlhttp_assign.readyState==4)
	  {
		parent.disableDiv();
		parent.document.getElementById("pop_div").innerHTML = xmlhttp_assign.responseText;
		parent.showPopDiv();
		parent.suggestTruck();
	  }
	}
	xmlhttp_assign.open("GET",url,true);
	xmlhttp_assign.send(null);	
}

function popConfirmAssign(id)
{
	xmlhttp_confirm=GetXmlHttpObject();
	if (xmlhttp_confirm==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }
	var url="ajax_pop_confirm.php";
	url=url+"?id="+id;
	xmlhttp_confirm.onreadystatechange=function (){
	  if (xmlhttp_confirm.readyState==4)
	  {
		parent.disableDiv();
		parent.document.getElementById("pop_div").innerHTML = xmlhttp_confirm.responseText;
		parent.showPopDiv();
	  }
	}
	xmlhttp_confirm.open("GET",url,true);
	xmlhttp_confirm.send(null);	
}

$(document).ready(function (){


		$( "#datepicker" ).datepicker();
		$( "#datepicker" ).datepicker( "option", "dateFormat", 'yy-mm-dd' );
		
		if($("#hfDate").val())
		{
		//$( "#datepicker" ).datepicker( "option", "defaultDate", $("#hfDate").val() );
		$( "#datepicker" ).val($("#hfDate").val());
		}

});


function changeDate(passed_date){
var size = document.getElementById('hfSize').value;
var fleet = document.getElementById('hfFleet').value;
var stat = document.getElementById('hfStat').value;

document.location.href = "queue_list.php?filter_date="+passed_date+"&size="+size+"&fleet="+fleet+"&stat="+stat;
}
function refreshList()
{
	var size = document.getElementById('hfSize').value;
	var fleet = document.getElementById('hfFleet').value;
	var stat = document.getElementById('hfStat').value;
	
	var hfdate = document.getElementById('hfDate').value;
	var ran = Math.floor(Math.random()*11);
	document.location.href = 'queue_list.php?filter_date='+hfdate+"&ran="+ran+"&size="+size+"&fleet="+fleet+"&stat="+stat;
}
</script>
</head>
<body onLoad='setTimeout("refreshList()",15000);'>
<table border='1' width='900' style='background-color:white;margin-left:auto;margin-right:auto;background-color:#5F0C0C;color:white;font-family:Georgia;font-size:12px'>
<th>QUEUE LIST</th>
</table>
<br />
<!--<div style='position:relative;left:55px;width:900px'><span style='font-family:Georgia;font-size:12px;color:white;font-weight:bold'>Date:&nbsp;</span><input type='text' id='datepicker' name='datepicker' onChange=changeDate(this.value);></div>
<input type='hidden' id='hfDate' name='hfDate' value='<?php echo $filter_date?>' />-->
<table width='900' style='background-color:black;margin-left:auto;margin-right:auto;color:white;font-family:Georgia;font-size:12px'>
<tr>
	<td align = 'left'>
		<span style='font-family:Georgia;font-size:12px;color:white;font-weight:bold'>Date:&nbsp;</span><input type='text' id='datepicker' name='datepicker' onChange=changeDate(this.value);>
		<input type='hidden' id='hfDate' name='hfDate' value='<?php echo $filter_date?>' />
		<input type='hidden' id='hfSize' name='hfSize' value='<?php echo $size?>' />
		<input type='hidden' id='hfFleet' name='hfFleet' value='<?php echo $fleet?>' />
		<input type='hidden' id='hfStat' name='hfStat' value='<?php echo $stat?>' />
	</td>
	<td align = 'right'><?php echo $search_string; ?>&nbsp;&nbsp;&nbsp;<input onClick='popSearch()' type = 'button' id = 'btn_asearch' name = 'btn_asearch' value = 'Advance Search' /></td>
</tr>
</table>
<table id='hor-minimalist-b' border='0' width='900' style='margin-left:auto;margin-right:auto'>
<thead>
<tr>
	<th>Status</th>
	<th>Booking Number</th>
	<th>Container</th>
	<th>Delivery Date</th>
	<th>Delivery Time</th>
	<th>Date/Time Received </th>
	<th>Tools </th>
</tr>
</thead>
<?php
while($row_queue = mysql_fetch_array($result_queue))
{

if($row_queue["status"]=="queue")
{
	$tools = "<img onClick='popAssign(".$row_queue['id'].")' src='image/assign_trucker.png' style='cursor:pointer' title='Assign a trucker' />";
}
if($row_queue["status"]=="for confirmation")
{
	$tools = "<img onClick='popConfirmAssign(".$row_queue['id'].")'; src='image/confirm.png' style='cursor:pointer' title='Confirm Trip Assignment' />";
}
?>
<tbody>
<tr>
	<td style="text-align:left; font-family:Georgia; font-size:12px">&nbsp;<?php echo strtoupper($row_queue["status"]) ?>&nbsp;</td>
	<td style="text-align:left; font-family:Georgia; font-size:12px">&nbsp;<?php echo $row_queue["booking_number"] ?>&nbsp;</td>
	<td style="text-align:left; font-family:Georgia; font-size:12px">&nbsp;<?php echo $row_queue["quantity"] ?>x<?php echo $row_queue["container_size"] ?>FTR&nbsp;</td>
	<td style="text-align:left; font-family:Georgia; font-size:12px">&nbsp;<?php echo $row_queue["positioning_date"] ?>&nbsp;</td>
	<td style="text-align:left; font-family:Georgia; font-size:12px">&nbsp;<?php echo $row_queue["positioning_time"] ?>&nbsp;</td>
	<td style="text-align:left; font-family:Georgia; font-size:12px">&nbsp;<?php echo $row_queue["receive_date_time"] ?>&nbsp;</td>
	<td style="text-align:left; font-family:Georgia; font-size:12px"><?php echo $tools ?></td>
</tr>
</tbody>
<?php
}
?>
</table>		
</body>
</html>

